package com.hhe.datax_transfer.controller;

import com.hhe.datax_transfer.cache.DataxJobMonitoringControl;
import com.hhe.datax_transfer.cache.ExecuteJobsQueue;
import com.hhe.datax_transfer.common.JsonResult;
import com.hhe.datax_transfer.common.ReceiptDefine;
import com.hhe.datax_transfer.service.TransferMonitoring;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * 数据迁移监控页面控制层
 *
 * @author HHe
 * @version V1.0
 * @date 2021/1/15 15:13
 */
@Slf4j
@Validated
@RestController
@RequestMapping("/transfer/monitoring")
@AllArgsConstructor(onConstructor_ = {@Autowired})
public class TransferMonitoringViewController {
    private TransferMonitoring transferMonitoring;

    /**
     * 系统监控汇总模板
     *
     * @version V1.0
     * @author HHe
     * @date 2021/1/25 19:49
     */
    @RequestMapping(value = "/importantsummariesmodel", method = RequestMethod.GET)
    public JsonResult importantSummariesModel() {
        return new JsonResult("200", ReceiptDefine.SELECT_SUCC, transferMonitoring.importantSummariesModel());
    }

    /**
     * 系统监控汇总
     *
     * @version V1.0
     * @author HHe
     * @date 2021/1/25 19:49
     */
    @RequestMapping(value = "/importantsummaries", method = RequestMethod.GET)
    public JsonResult importantSummaries() {
        return new JsonResult("200", ReceiptDefine.SELECT_SUCC, transferMonitoring.importantSummaries());
    }

    /**
     * 查询正在执行任务
     *
     * @version V1.0
     * @author HHe
     * @date 2021/1/16 9:32
     */
    @RequestMapping(value = "/queryrunningjoblist", method = RequestMethod.GET)
    public JsonResult queryRunningJobList() {
//        return new JsonResult("200", ReceiptDefine.SELECT_SUCC, ExecuteJobsQueue.getList());
        return new JsonResult("200", ReceiptDefine.SELECT_SUCC, DataxJobMonitoringControl.queryRunningJobList());
    }

    /**
     * 查询系统信息
     *
     * @version V1.0
     * @author HHe
     * @date 2021/1/16 9:33
     */
    @RequestMapping(value = "/querysystemmess", method = RequestMethod.GET)
    public JsonResult querySystemMess() {
        return new JsonResult("200", ReceiptDefine.SELECT_SUCC, transferMonitoring.querySystemMess());
    }

    /**
     * 查询执行线程池信息
     *
     * @version V1.0
     * @author HHe
     * @date 2021/1/16 9:33
     */
    @RequestMapping(value = "/queryexecutethreadpoolmess", method = RequestMethod.GET)
    public JsonResult queryExecuteThreadPoolMess() {
        return new JsonResult("200", ReceiptDefine.SELECT_SUCC, transferMonitoring.queryExecuteThreadPoolMess());
    }
}
